package com.weiwu.weiwustore.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weiwu.weiwustore.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    /**
     * 增加一条角色信息
     *
     * @param map 参数map
     * @return 受影响的行数
     */
    Integer addRole(Role map);

    /**
     * 查询所有的角色信息
     *
     * @return 所有角色信息
     */
    List<Role> findRoleAll();

    @Select("<script>" +
            "SELECT r.menus FROM `role` r,`user` u WHERE u.id = #{userid} AND r.id= u.roleid" +
            "</script>")
    String getMenusByUser(@Param("userid") Integer userid);
}
